﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Skynet.WebAdministracion.Views.ExamReview;
using Microsoft.Practices.Unity;

namespace Skynet.WebSite.Evaluation
{
    public partial class ExamReviewViewer : Infrastructure.Web.Views.Page, IExamReview
    {
        private ExamReviewPresenter _Presenter;
        [Dependency]
        public ExamReviewPresenter Presenter
        {
            get { return _Presenter; }
            set
            {
                _Presenter = value;
                this._Presenter.View = this;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                this.Presenter.OnViewInitialized();
            this.Presenter.OnViewLoaded();            
        }


        public List<object> Questions
        {
            set {
                this.GridView1.DataSource = value;
                this.GridView1.DataBind();
            }
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.GridView1.SelectedValue != null)
            {
                var key = (Guid)this.GridView1.SelectedValue;
                this.Presenter.ShowQuestion(key);
            }
        }

        protected void lbEndExam_Click(object sender, EventArgs e)
        {
            this.Presenter.EndExam();
        }
    }
}